-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix table listing in Iceberg to skip non-Iceberg tables #1354
Conversation
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/RecordingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/RecordingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/HiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/glue/GlueHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
@@ -176,7 +178,7 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect | |||
return schemaName.map(Collections::singletonList) | |||
.orElseGet(metastore::getAllDatabases) | |||
.stream() | |||
.flatMap(schema -> metastore.getAllTables(schema).stream() | |||
.flatMap(schema -> metastore.getTablesMatchingParameter(schema, TABLE_TYPE_PROP, ICEBERG_TABLE_TYPE_VALUE).stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the match case-sensitive or case-insensitive?
On our side we do case-insensitive, file
metastore it's case-sensitive and HMS thrift call may be case-sensitive (or it may actually depend on hms backend db collation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@electrum thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findepi @linxingyuan1102 The change introduces the problematic behavior as AFAIK case-sensitivity depends on HMS backend db collation and for derby db it is case-sensitive. This leads to iceberg tables that are created in spark using an upper case 'ICEBERG' type become hidden in show tables
while still valid and usable in queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/RecordingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
c67062e
to
3685028
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM form me. Let's wait for @findepi review
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/RecordingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
3685028
to
2ef434b
Compare
@findepi Thanks for the review. Comments addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Minor comments + a question to David.
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
...to-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Outdated
Show resolved
Hide resolved
2ef434b
to
e412b9f
Compare
Thanks. Comments addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Show resolved
Hide resolved
@@ -119,6 +120,9 @@ | |||
private volatile boolean metastoreKnownToSupportTableParamEqualsPredicate; | |||
private volatile boolean metastoreKnownToSupportTableParamLikePredicate; | |||
|
|||
private static final Pattern TABLE_PARAMETER_SAFE_KEY_PATTERN = Pattern.compile("^[a-zA-Z_]+$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is these a reference to what are the safe values for HMS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is one. See #1354 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phd3 this is documented in the code (where the constant is actually used, so there is a little bit more context).
Could you please check that explanation there? If it's not sufficient for a reader, we should improve it.
@@ -86,6 +87,7 @@ | |||
private final LoadingCache<String, List<String>> databaseNamesCache; | |||
private final LoadingCache<HiveTableName, Optional<Table>> tableCache; | |||
private final LoadingCache<String, List<String>> tableNamesCache; | |||
private final LoadingCache<List<String>, List<String>> tablesWithParameterCache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather create a different class for <databaseName, parameterKey, parameterValue>
than using a list to key the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can name it something liketableNamesCacheForPattern
for consistency with tableNamesCache
. both of them fetch tables for a database, the later one takes a filter into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can name it something like
tableNamesCacheForPattern
for consistency withtableNamesCache
. both of them fetch tables for a database, the later one takes a filter into account.
"Pattern" might not be very accurate because we use both =
and LIKE
when constructing the filter and we restrict the filter value to be alphanumeric. And I think it should be better if we just name the cache field after the method whose results it is caching. So I'd rather stay with tablesWithParameterCache
here.
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/RecordingHiveMetastore.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments, otherwise looks good
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
...to-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/main/java/io/prestosql/plugin/iceberg/IcebergMetadata.java
Show resolved
Hide resolved
presto-iceberg/src/test/java/io/prestosql/plugin/iceberg/TestIcebergMetadataListing.java
Show resolved
Hide resolved
37ee2dc
to
f5185b6
Compare
214e4f4
to
a086e9d
Compare
I've rebased the changes against master to resolve conflicts. Do we want to merge this if everything is okay? |
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
a086e9d
to
495770f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I will merge when Travis passes
(please ping me if I don't)
...to-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting this up into multiple commits. Very easy to review and see the different changes.
This is mainly used in tests.
Table listing in the Iceberg catalog should not include non-Iceberg tables.
495770f
to
ac43013
Compare
Merged, thanks! |
#1324
Tests done:
mvn clean install
builds successfully inpresto-hive
directory.TestIcebergMetadataListing
.mvn clean install
builds successfully inpresto-iceberg
directory.